package controller

import (
	"fx_swift_ifcgate_agent/api"
	"fx_swift_ifcgate_agent/internal/service"
	"fx_swift_ifcgate_agent/pkg/code"
	"fx_swift_ifcgate_agent/pkg/internalerrors"
	"github.com/gin-gonic/gin"
	"net/http"
)

// 获取boss端va开户成功的银行账户详情
func QueryVACallBackBossList(c *gin.Context) {
	merChantNo := c.Query("merChantNo")
	result, err := service.NewVAInfoSrv().QueryVACallBackBossList(c, merChantNo)
	if err != nil {
		code.Fail(c, http.StatusBadRequest, err.(internalerrors.ServiceError).Code, err.(internalerrors.ServiceError).Msg)
		return
	} else {
		code.Success(c, result)
	}
}

// 获取boss端va开户账户审核列表
func QueryVAInfoBossList(c *gin.Context) {
	req := &api.VAInfoBossReq{}
	if err := c.ShouldBindJSON(&req); err != nil {
		code.Fail(c, http.StatusBadRequest, code.ErrBind, err.Error())
		return
	}

	result, err := service.NewVAInfoSrv().QueryVAInfoBossList(c, req)
	if err != nil {
		code.Fail(c, http.StatusBadRequest, err.(internalerrors.ServiceError).Code, err.(internalerrors.ServiceError).Msg)
		return
	} else {
		code.Success(c, result)
	}
}

// 获取申请子类
func QueryApplyCode(c *gin.Context) {
	parentCode := c.Query("parentCode")
	result, err := service.NewVAInfoSrv().QueryApplyCode(c, parentCode)
	if err != nil {
		code.Fail(c, http.StatusBadRequest, err.(internalerrors.ServiceError).Code, err.(internalerrors.ServiceError).Msg)
		return
	} else {
		code.Success(c, result)
	}
}

// boss端获取账户持有人名称
func GetMerChantNameBoss(c *gin.Context) {
	merChantNo := c.Query("merChantNo")
	result, err := service.NewVAInfoSrv().GetMerChantName(c, merChantNo)
	if err != nil {
		code.Fail(c, http.StatusBadRequest, err.(internalerrors.ServiceError).Code, err.(internalerrors.ServiceError).Msg)
		return
	} else {
		code.Success(c, result)
	}
}
